package Thread;

import java.util.Random;
import java.util.Scanner;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/5/5
 * \* Time: 17:18
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class Demo1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {// 注意，如果输入是多个测试用例，请通过while循环处理多个测试用例
            int n = sc.nextInt();
            if(n == 0) break;
            int count = 0;
            while(n != 0){
                if(n == 1) break;

                if(n % 3 == 0){
                    n /= 3;
                }else{
                    n = n/3 +1;
                }
                count++;
            }
            System.out.println(count);
        }

    }

    //使用lambda表达式创建Runnable子类对象
    public static void main6(String[] args) {
        Thread t = new Thread(()->{
            System.out.println("使用lambada表达式创建");
        });
        t.start();
    }

    //匿名内部类创建Runnable 子类对象
    public static void main5(String[] args) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("使用匿名内部类创建Runnable对象");
            }
        });
        t.start();
    }

    public static void main4(String[] args) {
        Thread t1 = new Thread(){
            @Override
            public void run() {
                System.out.println("多线程");
            }
        };
        t1.start();
    }


    //方法二：实现Runable接口
    static class MyRunnable implements Runnable{
        @Override
        public void run() {
            System.out.println("这里是多线程运行的代码");
        }
    }

    public static void main3(String[] args) {
        Thread t = new Thread(new MyRunnable());
        t.start();
    }


    //创建多线程：方法一：继承Thread类
    static class MyThread2 extends Thread{
        @Override
        public void run() {
            System.out.println("这里是线程运行的代码");
        }
    }

    public static void main2(String[] args) {
        MyThread2 thread1 = new MyThread2();
        thread1.start();
    }



    private static class MyThread1 extends Thread{
        @Override
        public void run() {
            Random random = new Random();
            while (true){
                //打印线程名称
                System.out.println(Thread.currentThread().getName());
                try {
                    sleep(random.nextInt(10));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main1(String[] args) {
        MyThread1 thread1 = new MyThread1();
        MyThread1 thread2 = new MyThread1();
        MyThread1 thread3 = new MyThread1();

        thread1.start();
        thread2.start();
        thread3.start();


        Random random = new Random();
        while (true){
            //打印线程名称
            System.out.println(Thread.currentThread().getName());
            try {
                Thread.sleep(random.nextInt(10));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
